package org.theSeed.rbacSecurityJwt.config;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.theSeed.base.utils.RsaUtil;
import org.theSeed.rbacSecurityJwt.utils.LoginUtil;

import javax.annotation.PostConstruct;

@Slf4j
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "seed.jwt")
public class RbacSecurityConfig {
    /**
     * 公钥
     */
    private String publicKey;

    /**
     * 私钥
     */
    private String privateKey;

    @PostConstruct
    public void init(){
        log.info("系统jwt秘钥初始化开始");
        LoginUtil.setPrivateKey(RsaUtil.getPrivateKey("RSA",privateKey));
        LoginUtil.setPublicKey(RsaUtil.getPublicKey("RSA",publicKey));
        log.info("系统jwt秘钥初始化结束");
    }

}
